#ifndef OPERATEDB_H
#define OPERATEDB_H

#include <QObject>
#include <QSqlDatabase>

class OperateDB : public QObject
{
    Q_OBJECT
public:
    QSqlDatabase m_db; //数据库对象
    static OperateDB& getInstance();
    // 连接数据库
    void connect();
    ~OperateDB();

    bool handleResgist (const char* name, const char* pwd); // 处理注册请求
    bool handleLogin   (const char* name, const char* pwd); // 处理登录请求
    void handleOffline (const char* name);                  // 处理下线
    int  handleFindUser(const char* name);                  // 处理查找用户请求
    QStringList handleOnlineUser();                         // 处理在线用户请求
    int  handleAddFriend     (const char* caCurName, const char* caTarName); // 处理添加好友请求
    void handleAddFriendAgree(const char* caCurName, const char* caTarName); // 处理同意添加好友请求
    QStringList handleFlushFriend(const char* name); // 处理刷新好友请求
    int handleDelFriend(const char* caCurName, const char* caTarName); // 处理删除好友请求


signals:


private:
    // 单例模式
    explicit OperateDB(QObject *parent = nullptr);
    OperateDB(const OperateDB& instance)   = delete;
    OperateDB& operator=(const OperateDB&) = delete;
};

#endif // OPERATEDB_H
